<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<script type="text/javascript" src="cordova.js"></script>
<title>AlarmGap</title>
<script type="text/javascript">
var alarmJsonString = null;
var alarmJsonObj = null;

var alarmGapStop = function ( alarmId ) {

//if ( navigator.alarmgap )
// navigator.alarmgap.stopAlarm( alarmId );
//else
AlarmGapInterface.stopAlarm( alarmId );
};

var alarmGapSnooze = function ( alarmId, time ) {

//if ( navigator.alarmgap )
// navigator.alarmgap.snoozeAlarm( alarmId, time );
//else
AlarmGapInterface.snoozeAlarm( alarmId, time );
};

var alarmGapReceiveAlarm = function( _alarmJsonString ) {
console.log( "alarmGapReceiveAlarm called" );

alarmJsonString = _alarmJsonString;
alarmJsonObj = eval( "(" + alarmJsonString + ")" );

console.log( "alarmJsonString = " + alarmJsonString );

document.getElementById("alarmJson").innerHTML = "alarmJson = " + alarmJsonString;

document.getElementById("btnStop").onclick = function() {
console.log( "btnStop.onclick !!!" );

console.log( "alarmJSON = " + alarmJsonObj );
console.log( "navigator.alarmgap = " + navigator.alarmgap );

alarmGapStop( alarmJsonObj.alarmId );
};

document.getElementById("btnSnooze").onclick = function() {
console.log( "btnSnooze.onclick !!!" );

console.log( "alarmJSON = " + alarmJsonObj );
console.log( "navigator.alarmgap = " + navigator.alarmgap );

alarmGapSnooze( alarmJsonObj.alarmId, 10 * 1000 );
};

};

            var sample = {
// Application Constructor
initialize: function() {
this.bindEvents();
},
// Bind Event Listeners
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
onDeviceReady: function() {
sample.receivedEvent('deviceready');
},
// Update DOM on a Received Event
receivedEvent: function(id) {

}
            
            };
        </script>
<style>
.divFloat {
	float: left;
	width: 100%;
	text-align: center;
	word-wrap: break-word;
}
.divButton {
	width: 40%;
	float: left;
	margin: 2%;
	border-width: 1px;
	border-style: solid;
	border-color: #000;
	text-align: center;
	padding: 5px;
}
.divButton:active {
	background-color: #00F;
	color: #FFF;
}
#jsonObject {
	margin: 1%;
}
</style>
</head>
<body>
<div class="divFloat">
  <h1>AlarmGap - Alarm!!!</h1>
</div>
<div id="alarmJson" class="divFloat" > { "alarmJson" : "here" } </div>
<div id="areaDiv" class="divFloat">
  <div id="btnStop" class="divButton"> Stop </div>
  <div id="btnSnooze" class="divButton"> Snooze </div>
</div>
</body>
</html>